package cn.wbnyua.msm.web.api;

import cn.wbnyua.msm.util.JsonResponse;
import cn.wbnyua.msm.web.domain.Member;
import cn.wbnyua.msm.web.domain.Staff;
import cn.wbnyua.msm.web.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 作者：wbnyua.
 * 创建时间: 2023/2/8 22:58.
 */
@RestController
@RequestMapping("/api/staff")
public class StaffApi {

    @Autowired
    private StaffService service;

    @GetMapping
    public JsonResponse<List<Staff>> list(){
        return new JsonResponse<>(service.findAll());
    }

    @PostMapping
    public JsonResponse<String> add(Staff staff){
        service.add(staff);
        return JsonResponse.success();
    }

    @PutMapping
    public JsonResponse<String> update(Staff staff){
        service.update(staff);
        return JsonResponse.success();
    }

    @DeleteMapping
    public JsonResponse<String> remove(Long id){
        service.remove(id);
        return JsonResponse.success();
    }

}
